package com.example.lvsuo.mapper.cxg;

import com.example.lvsuo.entity.cxg.vo.FlowDataLine;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface MyThingMapper {


    @Select(" select system_role_id from  system_user_role where system_user_id = #{value} ")
    String getRid(int uid);

    @Select(" select fd.id fd_id, fd.fid, fd.fid_node, fd.data_table, fd.data_column, fd.applicant, fd.status,  fn.fname, su.* from flow_data fd inner join flow_name fn on fd.fid=fn.id inner join system_user su on fd.applicant=su.id where  fd.fid_node = #{value} and fd.status='Y' and fd.approval_status='1' ")
    List<Map<String, Object>> getMyDaiBan(String rid);

    @Select(" select id from flow_node where role_id = #{value} ")
    String getjiedianId(String rid);

    @Select(" select * from flow_line where fid = #{fid} and line_current = #{fid_node} ")
    FlowDataLine getNextId(Map<String, Object> map);

    @Update(" update flow_data set fid_node=#{lineNext} where id = #{fdId} ")
    void putJieDian(FlowDataLine nodeID);

    @Update(" update flow_data set fid_node=#{lineNext},approval_status=2 where id = #{fdId} ")
    void endPutJieDian(FlowDataLine nodeID);

    @Update(" update ${data_table} set ${approval_col}=2 where id = #{data_column} ")
    void TableFLowApproveStatus(Map<String, Object> map);

    @Select(" select * from (select column_name from information_schema.columns where table_name='${data_table}' and table_schema='lvsuo') colname where colname.column_name like '%approv%_status%'")
    String getApprovalCol(Map<String, Object> map);

    @Update(" update flow_data set fid_node=null,approval_status=3 where id = #{fd_id} ")
    void FlowBoHiu(Map rowData);

    @Update(" update ${data_table} set ${approval_col}=3 where id = #{data_column} ")
    void TableFLowBoHiuApproveStatus(Map<String, Object> map);
}
